package com.up.cloudfeiyibackend.config;

import com.up.cloudfeiyibackend.interceptor.JwtInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * WebMvc配置类
 */
@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {

    private final JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/user/login", 
                        "/user/register",
                        "/item/**",           // 非遗项目相关接口
                        "/event/pageQuery",   // 活动分页查询
                        "/event/category",    // 活动分类查询
                        "/event/countByCategory", // 活动数量查询
                        "/event/detail/**" ,   // 活动详情查询
                        "/event/regions"  // 活动区域查询
                );
    }
}
